package org.vectrics.site.hosted;

import org.vectrics.client.webclient.ServerCommandImpl;
import org.w3c.dom.Element;

public class EstablishSiteCommandRemote extends ServerCommandImpl {
	private HostedApplication hostedApplication = null;

	public EstablishSiteCommandRemote(HostedApplication application) {
		super();
		this.hostedApplication = application;
	}

	protected void processResponse(Element dataElement) {
	}

	protected void prepareRequestData(Element requestElement) {
		Element siteInfo = this.createElement(requestElement, "siteInfo");
		siteInfo.setAttribute("companyName", hostedApplication.getCompany().getName());
		siteInfo.setAttribute("companySectorCode", hostedApplication.getCompany().getSector().getCode());
		Element adminPerson = this.createElement(siteInfo, "adminPerson");
		adminPerson.setAttribute("lastname", hostedApplication.getPerson().getLastName());
		adminPerson.setAttribute("firstname", hostedApplication.getPerson().getFirstName());
		adminPerson.setAttribute("email", hostedApplication.getPerson().getContactInfo().getEmail());
		adminPerson.setAttribute("userName", hostedApplication.getPerson().getUser().getUserName());
		adminPerson.setAttribute("password", hostedApplication.getPerson().getUser().getPassword());
	}

	public String getCommandCode() {
		return "establish.hosted.site";
	}

}
